﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Transactions;
using System.Runtime.Serialization;

using Unis.Framework.ORM.Attributes;
using Unis.YLX.Data.Model;
using Unis.YLX.Service;
using Unis.Framework.RuleBase.Common;
using System.Data;

namespace ScmCostLedgerService
{    
    /// <summary> 
    /// 文件生成时间 2017/2/16 9:24:32
    /// </summary> 
    public class ScmCostledgerService :BaseService<ScmCostledgerInfo>, IScmCostledgerService
    {
        /// <summary>
        /// 删除实体对象
        /// 说明： 说明： 根据父表ID删除
        /// </summary>
        /// <param name="fid"></param>
        /// <returns></returns>
        public int DeleteEntityByStringFID(string fid)
        {
            int ret = DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQuery("ScmCostledger", "DeleteObjectByFid", fid);
            return ret;
        }
        /// <summary>
        /// 获取奖励、惩罚台账信息
        /// </summary>
        /// 
        /// <returns></returns>
        public DataTable GetCostLedgerReport(string type, DateTime? starttime, DateTime? endtime)
        {
            string param = "";
            if (type != null)
            {
                param = " where cl_type = " + type + "  ";
            } 
            if (starttime != null && endtime != null)
            {
                param += " and  cl_yearmonth between ''" + starttime + "'' and ''" + endtime + "'' ";
            }

            var dt = DatabaseExcuteByXmlHelper.NewInstance.GetDataSetByXml("ScmCostledger", "GetCostLedgerReport", param);
            return dt.Tables[0];
        }
    }

}

